//
//  ProfessorDetailViewController.m
//  Toyohu
//
//  Created by Heige on 16/4/28.
//  Copyright © 2016年 celia. All rights reserved.
//

#import "ProfessorDetailViewController.h"
#import "CoverTableViewCell.h"
#import "UIColor+FlatColors.h"
#import "CardView.h"
#import <MJRefresh.h>
#import "GPAFNetworking3.h"
#import <YYModel.h>
#import <UIImageView+WebCache.h>
#import <Masonry.h>
#import "MacroDefinition.h"
#import "RemarksCellHeightModel.h"


#import "AboutExpertTableViewCell.h"
#import "RemarksTableViewCell.h"
#import "ExpertCommentsTableViewCell.h"
#import "ExpertComentCollectionViewCell.h"
#import "ExpertSpaceTableViewCell.h"
#import "ExpertCommentCell.h"
#import "MoreCommentsTableViewCell.h"
#import "HomeSpaceTableViewCell.h"
#import "ProfessorTableViewCell.h"


#import "AboutExpertModel.h"
#import "GPCustomMD.h"
#import "ProfessorModel.h"
#import "ExpertCommentModel.h"
#import "UIViewController+ChangeStatus.h"
#import "TYH_LoginLoginModel.h"

#import "CustomSwipeableSubview.h"
#import "UIView+Fillet.h"
#import "ExpertDetailsDataModels.h"
#import <WebKit/WebKit.h>
#import <SafariServices/SFSafariViewController.h>
#import "UIViewController+ChangeStatus.h"

#define WIDTH self.view.bounds.size.width
#define HEIGHT self.view.bounds.size.height
#define ShowAllCellNOTIFICATION @"ShowAllCellNOTIFICATION"
#define MAXNUMBER 0
#define CLColor(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0f]
#define BOUNDS   [[UIScreen mainScreen] bounds]
static NSString *CoverTableViewCellReuseId = @"CoverTableViewCell";
static NSString *AboutExpertTableViewCellReuseId = @"AboutExpertTableViewCell";
static NSString *ExpertCommentsTableViewCellReuseId = @"ExpertCommentsTableViewCell";
static NSString *ExpertSpaceTableViewCellReuseId = @"ExpertSpaceTableViewCell";
static NSString *ExpertCommentCellReuseId = @"ExpertCommentCell";
static NSString *MoreCommentsTableViewCellReuseId = @"MoreCommentsTableViewCell";
static NSString *HomeSpaceTableViewCellReuseId = @"HomeSpaceTableViewCell";
static NSString *ProfessorTableViewCellReuseId = @"ProfessorTableViewCell";
@interface ProfessorDetailViewController ()<UITableViewDelegate,UITableViewDataSource,RemarksCellDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,SFSafariViewControllerDelegate>
{
    UITableView *myTableView;
    BOOL _isShow; // 是否展开
    NSString *_cellContentStr; // 备注消息
    NSMutableArray *aboutExpert;//顶部专家信息
    
    NSString *topName;
    NSString *tags;
    NSString *viewNum;
    NSString *pic;
    NSMutableArray *expertCommentArray;//行家点评数组
    NSMutableArray *similarExperts;//相关专家
    UIButton *button;
    
}
@property (nonatomic, strong) NSArray *colors;
@property (strong, nonatomic)UICollectionView *collectionView;
@property (nonatomic, strong) ExpertDetailsMsg *expertMsg;
@property (nonatomic, assign) NSInteger currentCardIndex;

@end

@implementation ProfessorDetailViewController
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [myTableView.mj_header beginRefreshing];
    [myTableView reloadData];
    
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self changeNaviBar];
    
//    SFSafariViewController *sfViewControllr = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:@"https://www.baidu.com"] ];
////    [self.navigationController pushViewController:sfViewControllr animated:YES];
////    [self presentViewController:sfViewControllr animated:YES completion:nil];
//    [self.navigationController pushViewController:sfViewControllr animated:YES];
//    
    topName = [NSString string];
    if (!aboutExpert) {
        aboutExpert = [NSMutableArray array];
    }
    
    if (!expertCommentArray) {
        expertCommentArray =[NSMutableArray array];

    }
    if (!similarExperts) {
        similarExperts = [NSMutableArray array];
    }
    
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    [self CreateNav];
    self.view.clipsToBounds = YES;
    self.view.backgroundColor = [UIColor whiteColor];

    [self CreateAppointment];
    [self getData];
    

}

-(void)CreateAppointment
{
    UIButton *mybutton = [UIButton buttonWithType:UIButtonTypeSystem];
    mybutton.frame = CGRectMake(0, HEIGHT-49, WIDTH, 49);
    [mybutton addTarget:self action:@selector(popAlert) forControlEvents:UIControlEventTouchDown];
    [mybutton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [mybutton setBackgroundColor:[UIColor orangeColor]];
    mybutton.titleLabel.font = [UIFont systemFontOfSize:15];
    [mybutton setTitle:@"立即预约" forState:UIControlStateNormal];
    [self.view addSubview:mybutton];
    
}

-(void)popAlert
{
    UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"提醒" message:@"专家忙" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [myAlert show];
}

-(void)CreateNav
{
    UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 64)];
    navView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:navView];
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    backButton.frame = CGRectMake(0, 5, 62, 64);
    [backButton addTarget:self action:@selector(backPreviousPage) forControlEvents:UIControlEventTouchUpInside];
    [navView addSubview:backButton];
    
    UIImageView *backImage = [[UIImageView alloc] init];
    backImage.image = [UIImage imageNamed:@"return-gray@2x"];
    backImage.bounds = CGRectMake(0, 0, 12, 20);
    backImage.center = backButton.center;
    [backButton addSubview:backImage];
    
    UIButton*shareButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [shareButton setBackgroundImage:[UIImage imageNamed:@"share@2x"] forState:UIControlStateNormal];
    [navView addSubview:shareButton];
    [shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(navView.mas_trailing).offset(-20);
        make.width.equalTo(@(18));
        make.height.equalTo(@(18));
        make.centerY.equalTo(navView.mas_centerY).offset(10);
    }];
    
    [self CreateTableView];
    
}

-(void)CreateTableView
{
    myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, WIDTH, HEIGHT-64-49) style:UITableViewStylePlain];
    myTableView.delegate = self;
    myTableView.dataSource = self;
    
    [myTableView registerNib:[UINib nibWithNibName:@"CoverTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:CoverTableViewCellReuseId];
    [myTableView registerNib:[UINib nibWithNibName:@"AboutExpertTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:AboutExpertTableViewCellReuseId];
    [myTableView registerNib:[UINib nibWithNibName:@"ExpertCommentsTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:ExpertCommentsTableViewCellReuseId];
    [myTableView registerNib:[UINib nibWithNibName:@"ExpertSpaceTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:ExpertSpaceTableViewCellReuseId];
    [myTableView registerNib:[UINib nibWithNibName:@"ExpertCommentCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:ExpertCommentCellReuseId];
    [myTableView registerNib:[UINib nibWithNibName:@"MoreCommentsTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:MoreCommentsTableViewCellReuseId];
    [myTableView registerNib:[UINib nibWithNibName:@"HomeSpaceTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:HomeSpaceTableViewCellReuseId];
    [myTableView registerNib:[UINib nibWithNibName:@"ProfessorTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:ProfessorTableViewCellReuseId];
    
    myTableView.showsVerticalScrollIndicator = NO;
    myTableView.showsHorizontalScrollIndicator = NO;
    myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.view addSubview:myTableView];
}
-(void)backPreviousPage
{
//    [self dismissViewControllerAnimated:YES completion:nil];
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark --FocueButton
-(void)focueButtonOn
{
  
    button = [self.view viewWithTag:300];
    
    if ([button.titleLabel.text isEqualToString:@"关注"]) {
        [button setTitle:@"已关注" forState:UIControlStateNormal];
        
    }
    else
    {
        [button setTitle:@"关注" forState:UIControlStateNormal];
    }
    NSString *pid = [[(NSDictionary *)GPGET(@"loginInfo") objectForKey:@"msg"] objectForKey:@"pId"];
    [GPAFNetworking3 post:LikeExpert parameters:@{@"pId":pid,@"eId":@(_eID)} progress:^(NSProgress * _Nullable progress) {
        
        
        
    } success:^(id  _Nullable responseObject) {
        
        if ([responseObject[@"msg"] isEqualToString:@"OK"]) {
            
        }
       
    } failure:^(NSString * _Nonnull errorLD) {
        
    }];
}
#pragma  mark --GetData
-(void)getData
{
    NSString *pid = [[(NSDictionary *)GPGET(@"loginInfo") objectForKey:@"msg"] objectForKey:@"pId"];
    
    [GPAFNetworking3 get:[NSString stringWithFormat:@"%@?pId=%@&eId=%ld",GetExpertInfo,pid,(long)_eID] progress:^(NSProgress * _Nonnull progress) {
        
    } success:^(id  _Nonnull responseObject) {
//       TYH_LoginLoginModel *myModel = [[TYH_LoginLoginModel alloc] initWithDictionary:responseObject];
        ExpertDetailsExpertDetailsBase *base = [[ExpertDetailsExpertDetailsBase alloc] initWithDictionary:responseObject];
        if (base.code !=1) {
            SHOW_ERROR
        }else{
            self.expertMsg = base.msg;
            AboutExpertModel *model = [[AboutExpertModel alloc]init];
            
            model.eName =base.msg.eName;
            model.eAppellation = base.msg.eAppellation;
            model.eViewNum = base.msg.eViewNum;
            model.eHeadUrl = base.msg.eHeadUrl;
            model.eInfo = base.msg.eInfo;
            model.subscription = base.msg.subscription;
            [aboutExpert addObject:model];
            
            
//            ExpertCommentModel *modelExpert = [[ExpertCommentModel alloc]init];
            [expertCommentArray removeAllObjects];
            for (ExpertDetailsExpertAppraise *appraise in base.msg.expertAppraise) {
                [expertCommentArray addObject:appraise];
            }
//            for (NSDictionary *dict in base.msg.expertAppraise) {
//                
//                modelExpert.eaAppraise = dict[@"eaAppraise"];
//                [modelExpert yy_modelSetWithDictionary:dict[@"Expert"]];
//                [expertCommentArray addObject:modelExpert];
//                [myTableView reloadData];
//                
//            }
//
            [similarExperts removeAllObjects];
            for (ExpertDetailsSimilarityExpert *expert in base.msg.similarityExpert) {
                [similarExperts addObject:expert];
            }
//            ProfessorModel *modelSimilar = [[ProfessorModel alloc]init];
//            for (NSDictionary*dict in base.msg.similarityExpert) {
//                [modelSimilar yy_modelSetWithDictionary:dict];
//                [similarExperts addObject:modelSimilar];
//                [myTableView reloadData];
//            }
            [myTableView reloadData];

        }
        
        
    } failure:^(NSString * _Nonnull errorLD) {
        SHOW_NTERROR
    }];

}

//-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
//{
//    if (section==1) {
//        
//                ZLSwipeableView *swipeableView = [[ZLSwipeableView alloc] initWithFrame:CGRectMake(0, 0, 280, 170)];
//                swipeableView.numberOfActiveViews  = 3;
//                self.swipeableView = swipeableView;
//        
//                self.swipeableView.dataSource = self;
//        
//                self.swipeableView.delegate = self;
//        
//                self.swipeableView.translatesAutoresizingMaskIntoConstraints = NO;
//        return swipeableView;
//    }
//    return nil;
//    
//    
//}
//
//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
//{
//    if (section==1) {
//        return 170;
//    }
//    return 0;
//    
//}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 9;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(section==0){
        return aboutExpert.count;
    }
    else if (section==1){
        return 1;
    }
    else if (section==2){
        return aboutExpert.count;
    }
    else if (section==3){
        return 1;
    }
    else if (section==4)
    {
        return 1;
    }
    else if (section==5)
    {
        return expertCommentArray.count;
    }
    else if (section==6)
    {
        return 1;
    }
    else if (section==7)
    {
        return 1;
    }else if (section==8)
    {
        return similarExperts.count;
    }
    return 0;
}




- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0) {
        CoverTableViewCell* cell = [[CoverTableViewCell alloc] init] ;

        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        cell.model = aboutExpert[indexPath.row];
        [cell.focusButton addTarget:self action:@selector(focueButtonOn) forControlEvents:UIControlEventTouchDown];
        cell.focusButton.tag = 300;
        cell.personalImg.userInteractionEnabled = YES;
        cell.focusButton.layer.borderColor = [UIColor cyanColor].CGColor;
        cell.focusButton.layer.borderWidth = 1;
        cell.focusButton.layer.cornerRadius = cell.focusButton.frame.size.height/2;
        cell.focusButton.clipsToBounds = YES;
        
        [cell.focusButton setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
        cell.img.userInteractionEnabled = YES;
        cell.swipeableView.dataSource = self;
        cell.swipeableView.delegate = self;
        cell.swipeableView.numberOfActiveViews  = self.expertMsg.article.count;
        [cell.swipeableView loadViewsIfNeeded];
        cell.swipeableView.translatesAutoresizingMaskIntoConstraints = NO;
        cell.swipeableView.allowedDirection = ZLSwipeableViewDirectionAll;
        [cell.swipeableView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(swipeableClick)]];
        cell.swipeableView.userInteractionEnabled = YES;
        [cell.swipeableView bringSubviewToFront:[[UIApplication sharedApplication] keyWindow]];
        return cell;
    }
    else if (indexPath.section==1&&indexPath.row==0)
    {
        AboutExpertTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:AboutExpertTableViewCellReuseId];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        if (!cell) {
            cell = (AboutExpertTableViewCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: AboutExpertTableViewCellReuseId];
        }
        return cell;
    }
    
    else if (indexPath.section==2)
    {
        static NSString *cellName = @"meTableViewCell";
        RemarksTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
        
        if (!cell) {
            cell = [[RemarksTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
            cell.delegate = self;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        
        AboutExpertModel *model = aboutExpert[indexPath.row];
        [cell setCellContent:model.eInfo andIsShow:_isShow  andCellIndexPath:indexPath];
        
        return cell;
    }
    else if (indexPath.section==3)
    {
        //myTableView.rowHeight=230;
        ExpertCommentsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ExpertCommentsTableViewCellReuseId];
        if (!cell) {
            cell = (ExpertCommentsTableViewCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: ExpertCommentsTableViewCellReuseId];
        }
        
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
        [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
        self.collectionView=[[UICollectionView alloc] initWithFrame:CGRectMake(10, 0, WIDTH, 225) collectionViewLayout:flowLayout];
        self.collectionView.dataSource=self;
        self.collectionView.delegate=self;
        [self.collectionView setBackgroundColor:RGB(236, 236, 236)];
        
        [self .collectionView registerNib:[UINib nibWithNibName:@"ExpertComentCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"ExpertComentCollectionViewCell"];
        [cell.contentView addSubview:self.collectionView];
        self.collectionView.showsHorizontalScrollIndicator = NO;
        
        cell.backgroundColor = [UIColor colorWithRed:236/255.0 green:236/255.0 blue:236/255.0 alpha:1];
        return cell;
    }
    else if (indexPath.section==4&&indexPath.row==0)
    {
       // myTableView.rowHeight = 44;
        ExpertSpaceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ExpertSpaceTableViewCellReuseId];
        
        if (!cell) {
            cell = (ExpertSpaceTableViewCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: ExpertSpaceTableViewCellReuseId];
        }
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        return cell;
    }
    else if (indexPath.section==5)
    {
       // myTableView.rowHeight = 93;
        ExpertCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:ExpertCommentCellReuseId];
        if (!cell) {
            cell = (ExpertCommentCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: ExpertCommentCellReuseId];
        }
        cell.model = expertCommentArray[indexPath.row];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        return cell;
    }
    else if (indexPath.section==6)
    {
       // myTableView.rowHeight = 77;
        MoreCommentsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MoreCommentsTableViewCellReuseId];
        if (!cell) {
            cell = (MoreCommentsTableViewCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: MoreCommentsTableViewCellReuseId];
        }
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        return cell;
    }
    else if (indexPath.section==7)
    {
       // myTableView.rowHeight = 44;
        HomeSpaceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:HomeSpaceTableViewCellReuseId];
        if (!cell) {
            cell = (HomeSpaceTableViewCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: HomeSpaceTableViewCellReuseId];
        }
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        cell.name.text = @"相关专家";
        return cell;
    }
    else if (indexPath.section==8)
    {
       // myTableView.rowHeight=113;
        ProfessorTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ProfessorTableViewCellReuseId];
        if (!cell) {
            cell = ( ProfessorTableViewCell*)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: ProfessorTableViewCellReuseId];
        }
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.model = similarExperts[indexPath.row];
        return cell;
    }
    return nil;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==2) {
        return [RemarksCellHeightModel cellHeightWith:_cellContentStr andIsShow:_isShow andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:400 andFixedHeight:200 andIsShowBtn:8];
//        return 100;
    }
    else if (indexPath.section==0&&indexPath.row==0)
    {
        return 440;
    }
    else if (indexPath.section==1&&indexPath.row==0)
    {
        return 51;
    }
    else if (indexPath.section==3){
        return 230;
    }
    else if (indexPath.section==4&&indexPath.row==0)
    {
        return 44;
    }
    else if (indexPath.section==5)
    {
        return 93;
    }
    else if (indexPath.section==6&&indexPath.row==0)
    {
        return 77;
    }
    else if (indexPath.section==7&&indexPath.row==0)
    {
        return 44;
    }
    else if (indexPath.section==8)
    {
        return 113;
    }
    return 0;
}
#pragma mark -- cellDalegate
- (void)remarksCellShowContrntWithDic:(NSDictionary *)dic andCellIndexPath:(NSIndexPath *)indexPath
{
    _isShow = [[NSString stringWithFormat:@"%@",[dic objectForKey:@"isShow"]] boolValue];
    
    [myTableView reloadData];
}

#pragma mark - ZLSwipeableViewDelegate


- (void)swipeableView:(ZLSwipeableView *)swipeableView
         didSwipeView:(UIView *)view
          inDirection:(ZLSwipeableViewDirection)direction {
    self.currentCardIndex ++;
    if (self.currentCardIndex == self.expertMsg.article.count) {
        self.currentCardIndex = 0;
        [myTableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
    }
}

- (void)swipeableClick
{
    SFSafariViewController *sfViewControllr = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:((ExpertDetailsArticle *)self.expertMsg.article[self.currentCardIndex]).aArticleUrl] entersReaderIfAvailable:YES];
    sfViewControllr.delegate = self;
    [self.navigationController pushViewController:sfViewControllr animated:YES];
}

#pragma mark ---------SFSafariViewControllerDelegate
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller
{
    [self.navigationController popViewControllerAnimated:YES];
//    [controller.navigationController popViewControllerAnimated:YES];
}

#pragma mark - ZLSwipeableViewDataSource
- (UIView *)nextViewForSwipeableView:(ZLSwipeableView *)swipeableView {
    CustomSwipeableSubview *sView = [[CustomSwipeableSubview alloc] initWithFrame:swipeableView.bounds];
    [sView filletWithcornerRadius:5.0f];
    int index = [[[swipeableView valueForKey:@"_containerView"] valueForKey:@"_countOfTraitChangeRespondersInDirectSubtree"] intValue];
    if (index >= self.expertMsg.article.count) {
        return nil;
    }
    ExpertDetailsArticle *article = self.expertMsg.article[index];
    sView.watchNumberLabel.text = [NSString stringWithFormat:@"%.f",article.aViewNum];
    sView.titleLabel.text = article.aTitle;
    sView.detailsLabel.text = article.aAbstract;
    sView.tagLabel.text = article.aTags;
    return sView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}

#pragma mark -------UICollectionView
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return expertCommentArray.count;
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * CellIdentifier = @"ExpertComentCollectionViewCell";
    ExpertComentCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    cell.type.layer.cornerRadius = cell.type.frame.size.height/2;
    cell.type.clipsToBounds = YES;
    cell.type.backgroundColor = [UIColor colorWithRed:254/255.0 green:214/255.0 blue:17/255.0 alpha:1];
    cell.model = expertCommentArray[indexPath.row];
    cell.layer.cornerRadius = 5;
    cell.clipsToBounds = YES;
    
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(345, 215);
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(5, 5, 5, 5);
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
}
@end
